package com.atguigu.cloud.exception;

import com.atguigu.cloud.enums.ReturnCodeEnum;
import com.atguigu.cloud.resp.ResultData;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 全局异常处理器
 *
 * @author Kotori rotroutine@163.com
 * @since 2025/2/28
 */
@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    public ResultData<?> handleException(Exception e) {
        log.error(e.getMessage(), e);
        return ResultData.fail(ReturnCodeEnum.RC500, e.getMessage());
    }
}
